#ifndef JSON_DATA_HPP
#define JSON_DATA_HPP
#include <jsoncpp/json/json.h>
#include <string>
#include <cstring>
#include <iostream>
class JsonData_sensor_convert
{
    public:
      JsonData_sensor_convert(){}
      ~JsonData_sensor_convert(){}
    //example
    // double seatx,seaty,seatz;
    // int count;
    // std::string name;  
    std::string json_msg;
    double distance_up,distance_down;
    double dis_L,dis_R,dis_F,dis_B;
    int motor_cur_speed,motor_set_speed;
    int key_value=0;
    void receive_msg(std::string &msg);
    void set_json_msg(void);
};
void JsonData_sensor_convert::receive_msg(std::string &msg)
{
     Json::Reader reader;
     Json::Value json_val;
     if(reader.parse(msg, json_val))
     {
        // distance_up = json_val["distance_up"].asDouble();  //asInt  asString
        // distance_down = json_val["distance_down"].asDouble();
        key_value = json_val["key_value"].asInt();
       // name = json_val["name"].asString();
     }
}
void JsonData_sensor_convert::set_json_msg(void)
{
    Json::Value json_val;
        json_val["motor_cur_speed"] = motor_cur_speed;
        json_val["distance_up"] = distance_up;
        json_val["distance_down"] = distance_down;
        json_val["dis_L"] = dis_L;
        json_val["dis_R"] = dis_R;
        json_val["dis_F"] = dis_F;
        json_val["dis_B"] = dis_B;
        // json_val["seatx"] = seatx;
        // json_val["seaty"] = seaty;
        // json_val["seatz"] = seatz;
        // json_val["name"] = name;
        json_msg = json_val.toStyledString();
}

#endif